// 类
class persons{
      name:string
      age:number
      constructor(name:string,age:number){
              this.name=name
              this.age=age
      }
      speak(){
        console.log(`我叫${this.name}今年${this.age}岁`);
      }
}
let p1=new persons('韩立',30)
console.log(p1);
p1.speak()


// 继承
class student extends persons{
    city:string
    constructor(name:string,age:number,city:string){
       super(name,age)
       this.age=age
       this.city=city
    }
    study() {
        console.log(`我叫${this.name}今年${this.age}岁,在努力学习...，家在${this.city}`);
    }
    // override添加这个防止重写错单词
    override speak() { 
    }
}
let s1=new student('李潇',12,'湖南')
s1.speak()



// 类简写

class persons1{
    // 也就是不用再什么声明属性直接加个修饰符就可以简写了
    constructor(public name:string,public age:number){
            this.name=name
            this.age=age
    }
    speak(){
      console.log(`我叫${this.name}今年${this.age}岁`);
    }
}
